#ifndef RESOURCE_HPP_INCLUDED
#define RESOURCE_HPP_INCLUDED

#include <boost/shared_ptr.hpp>

#include <string>

#include "SDL.h"

#include "formula.hpp"
#include "item.hpp"
#include "item_type.hpp"
#include "resource_fwd.hpp"
#include "texture.hpp"
#include "wml_node_fwd.hpp"

class resource
{
public:
	struct parse_error {};
	static const std::vector<const_resource_ptr>& get_global_resources();
	static void init(wml::const_node_ptr node);
	static const_resource_ptr get(const std::string& key);

	explicit resource(wml::const_node_ptr node);

	const std::string& id() const { return id_; }
	const std::string& produces() const { return item_type_->id(); }
	const std::string& uses() const;
	const std::string& specialization() const { return specialization_; }
	const std::string& improvement() const { return improvement_; }
	const game_logic::const_formula_ptr& level_up() const { return level_up_; }
	int production_rate() const { return production_rate_; }
	item produce() const;

	int weather_bonus(int weather, int river) const;

	const SDL_Color& color() const { return color_; }

	const_item_type_ptr input() const;

	void draw(int quality, int x, int y) const;

private:
	std::string id_;
	const_item_type_ptr item_type_;
	const_item_type_ptr input_item_type_;
	std::string specialization_;
	std::string improvement_;
	game_logic::const_formula_ptr level_up_;
	SDL_Color color_;
	int production_rate_;
	game_logic::const_formula_ptr weather_bonus_;

	graphics::texture texture_;
	int min_quality_for_texture_;

	bool global_;
};

#endif
